package com.ctg.behavior.calc.common;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

public class CtSQLParam {

	private Map<String, String> params = new HashMap<String, String>();

	public void addParam(String key, String value) {
		if (StringUtils.isEmpty(key)) {
			return;
		}
		params.put(key, value);
	}

	public String getParam(String key) {
		if (StringUtils.isEmpty(key)) {
			return null;
		}
		return params.get(key);
	}

	public String delParam(String key) {
		if (StringUtils.isEmpty(key)) {
			return null;
		}
		return params.remove(key);
	}

	public static CtSQLParam createParam() {
		CtSQLParam param = new CtSQLParam();
		return param;
	}

	public static CtSQLParam createAliasParam(String alias) {
		CtSQLParam param = new CtSQLParam();
		param.addParam(CtSQLConsts.KEY_ALIAS, alias);
		return param;
	}

	public static CtSQLParam addAlias(CtSQLParam param, String alias) {
		param.addParam(CtSQLConsts.KEY_ALIAS, alias);
		return param;
	}

	public static CtSQLParam createFilterParam(String filterSQL) {
		CtSQLParam param = new CtSQLParam();
		param.addParam(CtSQLConsts.KEY_FILTER_SQL, filterSQL);
		return param;
	}

}
